package com.clw.template.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.clw.template.entity.YhAd;
import com.clw.template.mapper.YhAdMapper;
import com.clw.template.service.IYhAdService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 广告表 服务实现类
 * </p>
 *
 * @author clw
 * @since 2019-11-23
 */
@Service
public class YhAdServiceImpl extends ServiceImpl<YhAdMapper, YhAd> implements IYhAdService {

    @Override
    public IPage<YhAd> adminList(Integer pageNum, Integer pageSize) {
        Page<YhAd> page = new Page<>(pageNum,pageSize);
        return page(page);
    }

    @Override
    public void add(YhAd ad) {
        ad.setAddTime(LocalDateTime.now());
        ad.setUpdateTime(ad.getAddTime());
        save(ad);
    }

    @Override
    public void deleted(List<Long> ids) {
        removeByIds(ids);
    }

    @Override
    public void edit(YhAd ad) {
        updateById(ad);
    }
}
